/**
 * Created by chengming on 18/5/27.
 * version 1.0
 */
const BaseJsonAdapter = require('../base/BaseJsonAdapter');
const iconv = require("iconv-lite");
const vm = require('vm');

module.exports = class SinaFin extends BaseJsonAdapter{
	async reqJson(){
		const body = await this.doRequest();
		let decodeBody = iconv.decode(body, this.encoding).toString();
		vm.runInThisContext(decodeBody);

		if(jsonData && jsonData.list){
			for(let item of jsonData.list){
				if(item.url && item.url.indexOf('http://finance.sina.com.cn') != -1
					&& item.url.indexOf('https://finance.sina.com.cn') != -1){
					item.url = item.url.replace(/http:\/\/finance.sina.com.cn/g, '');
				}
			}
		}
		return jsonData;
	}
}
